(* file : type.ml
contains internal types
Arnaud Aujon   AUJA31018906
*)


exception NotFound  
exception TypeError
exception ParseError

type t1_if_int = 
    If of (t1_expr * (t1_expr list))
  | Else of (t1_expr list)

(* this type is return by parser *)
and t1_expr = 
  Int of int
  | Float of float
  | Bool of bool
  | String of string
  | Var of string
  | Array of ( t1_expr list)
  | Array_index of string * t1_expr
  | Unary of string * t1_expr 
  | Print of (t1_expr list)
  | Assignment of t1_expr * t1_expr
  | Binary of t1_expr * string * t1_expr
  | Struct_If of ( t1_if_int list)
  | While of (t1_expr * t1_expr list)
  | For of (t1_expr * t1_expr * t1_expr * (t1_expr list) )
  | Decl_Function of (string * string list * (t1_expr list))
  | Function of (string * (t1_expr list) )
  | Return of t1_expr
;;

type t2_if_int = 
    T2_If of (t2_move * (t2_move list))
  | T2_Else of (t2_move list)

(* this type is return after move phase*)
and t2_move =
  T2_Int of int
  | T2_Float of float
  | T2_Bool of bool
  | T2_String of string
  | T2_Var of string
  | T2_Array of t2_move list
  | T2_Array_index of string * t2_move
  | T2_Unary of string * t2_move 
  | T2_Print of (t2_move list)
  | T2_Assignment of t2_move * t2_move
  | T2_Decl_Var of string
  | T2_Binary of t2_move * string * t2_move
  | T2_Struct_If of ( t2_if_int list)
  | T2_While of (t2_move * t2_move list)
  | T2_For of (t2_move * t2_move * t2_move * (t2_move list) )
  | T2_Decl_Function of (string * string list * (t2_move list))
  | T2_Function of (string * (t2_move list) )
  | T2_Return of t2_move
  | T2_Nil
;;
type t3_if_int = 
    T3_If of (t3_inf * (t3_inf list))
  | T3_Else of (t3_inf list)

(* this type is return after inference phase,
it contains some type informations *)
and t3_inf = 
  T3_Int of int
  | T3_Float of float
  | T3_Bool of bool
  | T3_String of string
  | T3_Var of string
  | T3_Array of ( t3_inf list)
  | T3_Pointer of string (* => & de C *)
  | T3_Array_index of string * t3_inf
  | T3_Unary of string * t3_inf 
  | T3_Print of (t3_inf list)
  | T3_Typed_Assignment of vType * t3_inf * t3_inf
  | T3_Typed_Decl_Function of string * ((string * vType) list) * (t3_inf list)
  | T3_Typed_Decl_Var of string * vType
  | T3_Decl_Var of string (* try to remove that later *)
  | T3_Binary of t3_inf * string * t3_inf
  | T3_Struct_If of ( t3_if_int list)
  | T3_While of (t3_inf * t3_inf list)
  | T3_For of (t3_inf * t3_inf * t3_inf * (t3_inf list) )
  | T3_Function of (string * (t3_inf list) )
  | T3_Return of t3_inf
  | T3_Nil

(* real value type *)
and vType =
    TInt
  | TFloat
  | TBool
  | TString
  | TArray
  | TArray_int
  | TArray_index
  | TObjVar of vType
  | TNil
;;